home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-09 | 6.9 KB | 315 lines | [TEXT/MSET] |
- \ Front end for Mops.
-
- \ EVENTLOOP is a word you can use in installed applications, or during
- \ testing if you have other windows up besides fWind. If one of the
- \ other windows is in front, typed keys are sent to it via KEY:. If
- \ fWind is in front, typed keys are interpreted. Your other windows
- \ will need an Activate handler which calls EventLoop.
-
- : EVENTLOOP \ 30Apr94 DBH, incredibly simple
- BEGIN
- next: fevent \ next: no longer returns a boolean
- AGAIN ;
-
-
- \ Some objects needed by QE and TEfwindMod
-
- handle QEhand \ a place for the handle passed in from Quick Edit
- string+ QEstr
- false value ClrStk? \ true if we're to clear stack on next idle
- \ or update
-
- ' drop vect .CELL
-
- : (.CELL) \ ( adr -- )
- @ . ;
-
- ' (.cell) -> .cell \ This is enhanced when FP loaded
-
-
- window DW \ For display of source text during debugging
-
- forward setTW
-
- from EXTRASMOD
- IMPORT{ l rl cl fm need +log -log (create_log) (write_log)
- locate_src addr>curs move_curs ?open_in_QE
- edit openSource def??
- redraw use_module
- 1up 1dn 1lft 1rt homex end defnup defndn selectdw
- prof_str }
-
- : LOCATE openSource ; \ a better name, I think
-
- :f CREATE_LOG (create_log) ;f
- :f WRITE_LOG (write_log) ;f
-
- compile: extrasMod
-
- ' null vect ABOUTVEC \ So AppleMen can be reused as is by
- \ applications.
-
- ' bye vect BYEVEC \ Our new TE interface needs to do some extra things
-
-
- \ Define the menus for the Mops menu bar:
-
- 2 AppleMenu APPLEMEN
- 6 menu FILEMEN
- 9 EditMenu EDITMEN
- 3 menu LISTMEN
- 3 menu SHOWMEN
- 6 menu UTILMEN
-
-
- \ PowerPC assembler:
-
- from pasmMod import{ :PPC_code ;PPC_code
- disasm disasm_word disasm_xt
- disasm_rng disasm_cnt disasm_one
- set_disasm_call_range }
-
- compile: pasmMod
-
-
- \ Support code for our TEwind interface:
-
- string+ TWstr
-
- forward NEWVECS
- forward OLDVECS
-
- false value PROMPT?
-
- forward run_TE
- forward .room
- forward doPref
- forward nimpl
- forward flush_TWstr
-
-
- from TEFwindMod import{ do_run_TE TEFwind bye+ evalFromQE
- xUndo xCut xCopy xPaste xClear xSelAll }
-
- from FEMOD import{ (about) save
- enFW disFW save stdSave doSave
- doUndo doCut doCopy doPaste doClear doSelAll xPref
- doOlist doClist x.room xNimpl
- Lecho doPurge
- get_appl_name get_appl_vers get_appl_sig
- set_appl_name set_appl_vers set_appl_sig
- run_FE }
-
- :f .room x.room ;f
- :f doPref xPref ;f
- :f nimpl xNimpl ;f
-
- compile: FEmod
- compile: TEFwindMod
- lock: TEFwindMod
-
- TEFwind TW
-
- screenbits true setGrow: tw
- true setZoom: tw
-
-
- : TWPORT? \ The vecs only need to be different if TW is the grafport
- savePort thePort @ addr: tw = ;
-
- : ERR_SRC
- topFile nilP <>
- IF \ We try to open the source in QE. We don't use LOCATE_SRC
- \ since here we only want a source display if it's QE.
- topFile ?open_in_QE
- pos: topFile move_curs
- THEN
- TWport?
- IF -echo 0 -> (err#) \ Clear error indicator from AppleEvents
- dflt-err \ Display error info and abort
- ELSE (ddie)
- THEN ;
-
- ' err_src -> dflt-die
-
- :f FLUSH_TWstr
- pos: TWstr 0EXIT
- lock: TWstr
- all: TWstr insert: TW
- unlock: TWstr
- clear: TWstr ;f
-
-
- : XEMIT \ ( char -- )
- TWport?
- IF +: TWstr
- ELSE (emit)
- THEN ;
-
- : XCR
- TWport?
- IF RET xemit flush_TWstr
- ELSE (cr)
- THEN ;
-
- : XTYP \ ( addr len -- )
- TWport?
- IF add: TWstr
- ELSE (type)
- THEN ;
-
- : XSPS \ Replacement for SPACES
- TWport?
- IF dup 0<= IF drop EXIT THEN
- pad swap 2dup bl fill
- add: TWstr
- ELSE (spaces)
- THEN ;
-
- : XQUIT
- RP0 RP! eventloop ; \ QUIT will now always come back to EventLoop
-
-
- :f NEWVECS
- ['] xemit -> emitvec
- ['] xcr -> crvec
- ['] xtyp -> typevec
- ['] xsps -> spvec
- ['] xemit -> echovec
- ['] setTW -> setfWind
- ['] xquit -> quitvec
- ['] bye+ -> byevec
- ;f
-
- :f OLDVECS
- ['] (emit) -> emitvec
- ['] (cr) -> crvec
- ['] (type) -> typevec
- ['] (spaces) -> spvec
- ['] (emit) -> echovec
- ['] (sf) -> setfWind
- \ 0 -> quitvec \ mh May94 - quit doesn't get changed any more
- ['] bye -> byevec
- ;f
-
-
- :f RUN_TE
- load: TEFwindMod lock: TEFwindMod \ May have been purged
- new: TWstr \ 31Jan94 DBH
- TW do_run_TE
- ;f
-
- :f setTW select: TW set: TW enable: TW ;f
-
-
-
- \ ================= start of QE-related code ===================
-
- \ The following words are called from QE, by QE sending us a string to
- \ EVALUATE.
-
- \ StackClear clears the stack - we don't do the actual clear straight away,
- \ since the Mops system might have a variable number of cells in use.
- \ Instead we set clrStk? true, so that we'll handle it when our window TW
- \ gets idle: or update:, when things are consistent.
-
- : STACKCLEAR
- true -> clrStk? ;
-
-
- \ ClrWind is used by the QE and Mops menu item "Clear Window".
-
- : ClrWind
- fWind?
- IF cls
- ELSE selAll: TW clear: TW
- actW TW <> \ this seems to be necessary if TW isn't frontmost
- IF getRect: TW put: tempRect clear: tempRect THEN
- THEN ;
-
-
- \ Now we have the words which support high-level events from Quick Edit.
- \ (Note these aren't AppleEvents.)
- \ Thanks to Doug Hoffman for these.
-
-
- : DoHLevent \ ( -- b )
- msgClass: fEvent 'type TEXT = \ a simple check for proper class
- IF
- msgID: fEvent put: QEhand \ message ID is merely the handle from QE
- ptr: QEhand size: QEhand put: QEstr
- evalFromQE fWind? NIF update: TW cr THEN \ 01Feb94 DBH Need the cr to insert: tw
- true \ we did handle the event
- ELSE
- false \ we did not handle the event
- THEN
- ;
-
- : InitQE
- instld? ?EXIT \ Mustn't do this in installed apps
- true -> resume?
- ['] DoHLevent -> HLeventVec
- new: QEstr
- ;
-
- ' InitQE add: init_actions
-
-
- \ =========== End of QE-related code ==================
-
-
- 0 value TEMPA5 \ Used by DebugMod while we're getting
- \ addressable. Must be in main dic.
- 0 value LAST_TIME \ These 3 are used by DebugMod when profiling.
- 0 value NOW
- 0 value THIS_BP
-
- from DEBUGMOD import{ in notin (see) see debug unbug resume show
- profile showp }
-
- from INSTLMOD import{ install }
-
- from UTILMOD import{ .mods .msgs addmsg removemsg getindstr }
-
- from ALERTQMOD import{ (al) }
-
- xts{ aboutVec doDsk } 1 init: appleMen
-
- xts{ L null doSave stdSave null byevec } 2 init: FileMen
-
- \ xts{ doUndo null doCut doCopy doPaste doClear doSelAll null xPref }
- \ 3 init: EditMen
-
- xts{ words doOlist doClist } 4 init: ListMen
-
- xts{ .paths .room .mods } 5 init: ShowMen
-
- xts{ LEcho stackClear ClrWind null install doPurge }
- 6 init: UtilMen
-
-
- : RUN \ System startup word for the Mops development environment.
- sysinit run_FE ;
-
- ' run -> objinit
-
- 20 -> sleepticks \ Default value - allows a time display
- \ to be updated reasonably.
-
- false -> fwind? \ Default is our new TE window. This will now
- \ be permanent for the Mops development
- \ environment.
-
- compile: FEmod
- compile: utilmod
- compile: debugmod
- compile: instlmod
-
-
- cr cr cr
- .( The Mops system is compiled. Now save the dictionary, by typing e.g.) cr
- .( save Mops.dic) cr
- .( then type bye to quit, and after that you'll be able to fire up the) cr
- .( newly-compiled dictionary.) cr cr
-
-